package xyz.chaobei.mapper;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;
import xyz.chaobei.entity.OrgRoleEntity;

import java.util.List;

/**
 * mapper
 * @author mrc
 */
public interface OrgRoleMapper extends BaseMapper<OrgRoleEntity> {

    /**
     * 通过用户id查询出多个角色信息
     * @param id
     * @return
     */
    List<OrgRoleEntity> findByUserId(@Param("id") Integer id);

    /**
     * 查询用户对应的多个角色信息
     * @param id
     * @return
     */
    @Select("SELECT role_id_ FROM `org_user_role` WHERE user_id_ = #{id}")
    List<Integer> findRoleIdsByUserId(@Param("id")Integer id);

    @Select("SELECT * FROM `org_role` WHERE `status_` = 1")
    List<OrgRoleEntity> list();
}